package com.spzx.product.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.common.core.web.page.TableDataInfo;
import com.spzx.product.api.SpzxService;
import com.spzx.product.api.domain.*;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author ChenXing
 * @Description 这个降级类扫描不出来，可以单独走后门
 * @Create 2024/8/7 22:42
 */
@Component
public class SpzxServiceFallback implements FallbackFactory<SpzxService> {

    @Override
    public SpzxService create(Throwable cause) {

     return   new SpzxService() {

         @Override
         public R<List<CategoryVo>> getOneCategory(String source) {
             System.out.println("getOneCategory方法异常，返回兜底结果");
             return R.fail(cause.getMessage());
         }

         @Override
         public R<List<ProductSku>> getTopSale(String source) {
             System.out.println("getTopSale方法异常，返回兜底结果");
             return R.fail(cause.getMessage());
         }

         @Override
         public R<TableDataInfo> skuList(Integer pageNum, Integer pageSize, SkuQuery skuQuery, String source) {
             System.out.println("skuList方法异常，返回兜底结果");
             return R.fail(cause.getMessage());
         }

         @Override
         public R<List<Brand>> getBrandAll(String source) {

             System.out.println("getBrandAll方法异常，返回兜底结果");
             return R.fail(cause.getMessage());

         }

         @Override
         public R<ProductSku> getProductSku(Long skuId, String source) {

             System.out.println("getProductSku方法异常，返回兜底结果");
             return R.fail(cause.getMessage());

         }

         @Override
         public R<Product> getProduct(Long skuId, String source) {
             System.out.println("getProduct方法异常，返回兜底结果");
             return R.fail(cause.getMessage());
         }

         @Override
         public R<SkuPrice> getSkuPrice(Long skuId, String source) {
             System.out.println("getSkuPrice方法异常，返回兜底结果");
             return R.fail(cause.getMessage());
         }

         @Override
         public R<ProductDetails> getProductDetails(Long skuId, String source) {
             System.out.println("getProductDetails方法异常，返回兜底结果");
             return R.fail(cause.getMessage());
         }

         @Override
         public R<SkuStockVo> getSkuStockVo(Long skuId, String source) {
             System.out.println("getSkuStockVo方法异常，返回兜底结果");
             return R.fail(cause.getMessage());
         }

         @Override
         public R<List<ProductSku>> getProductSkuList(Long id, String source) {
             System.out.println("getProductSkuList方法异常，返回兜底结果");
             return R.fail(cause.getMessage());
         }

         @Override
         public R<List<SkuPrice>> getSkuPriceList(List<Long> skuIds, String source) {
             System.out.println("getSkuPriceList方法异常，返回兜底结果");
             return R.fail(cause.getMessage());
         }

         @Override
         public R<String> checkAndLock(String tradeNo, List<SkuLockVo> skuLockVoList, String source) {
             System.out.println("checkAndLock方法异常，返回兜底结果");
             return R.fail(cause.getMessage());
         }



     };
    }
}

